<?php
namespace AppBundle\Service;
use Psr\Log\LoggerInterface;
class MessageGenerator{

    private $logger;
    private $loggingEnabled;

    public function setLogger(LoggerInterface $logger,$loggingEnabled)
    {
        $this->logger=$logger;
        $this->loggingEnabled=$loggingEnabled;
    }

    public function getHappyMessage(){

        if($this->loggingEnabled ){
            $this->logger->log('info','About get happy message');
        }
        $message = [
            '你做到了，坚持！',
            '恭喜你，你升级成功！'
        ];

        $index = array_rand($message);

        return $message[$index];
    }
}